<?php
require_once 'inc_security.php';
$action = getValue('action','str','POST','');
switch($action){
    case 'alias':
        $title = getValue('title','str','POST','');
        echo removeTitle($title);
    break;
    case 'search_relate':
        $keyword = getValue('keyword','str','POST','');
        if(!$keyword){
            break;
        }
        $str = '';
        $result = db_array('SELECT acc_id,acc_name
                                FROM accessories
                                WHERE acc_active = 1
                                    AND (acc_name LIKE "%'.$keyword.'%")
                                ORDER BY acc_name ASC
                                LIMIT 10' );
        $result = array_unique($result,SORT_REGULAR);
        if($result){
            foreach($result as $lir){
                $str .= '
                    <li>
                        <label class="checkbox">
                            <input type="checkbox" title="'.$lir['acc_name'].'" value="'.$lir['acc_id'].'" class="pro_relate_result" id="search_pro_relate_'.$lir['acc_id'].'"/>
                            '.$lir['acc_name'].'
                        </label>
                    </li>';
            }
            $str .= '<span class="label label-info" style="cursor:pointer" onclick="ProductJS.add_relate()">Thêm vào</span>';
        }
        echo $str;
    break;
}
?>